/*
 * @Author: YuA
 * @Date: 2021-08-04 01:49:54
 * @LastEditTime: 2021-08-21 10:41:53
 * @FilePath: \index\src\network\request.js
 */
import axios from "axios";

export function request(config) {
  const instance = axios.create({
    baseURL: "/api",
    timeout: 5000
  });
  // axios拦截器

  //1.请求拦截
  instance.interceptors.request.use(
    config => {
      return config;
    },
    err => {
      console.log(err);
    }
  );

  //2相应拦截
  instance.interceptors.response.use(
    res => {
      return res.data;
    },
    err => {
      console.log(err);
    }
  );

  //3发送真正的网络请求
  return instance(config);
}
